var express = require('express');
var router = express.Router();
var orderModel = require('../../models/order/order_list');


//定义路由，当访问该路由的时候，去数据库查找信息并返回
router.post('/', function (req, res, next) {
    var params = req.body
    var type = ['express-pic', 'shopping-pic', 'other-pic']
    orderModel.find({ _id: params._id }, function (err, docs) {
        if (docs[0].picture.length !== 0) {
            let picUrlArr = []
            for (let i = 0; i < docs[0].picture.length; i++) {
                picUrlArr.push(`http://localhost:3000/images/${type[params.type]}/${docs[0].picture[i]}`)
            }
            res.json({ data: picUrlArr, msg: '返回成功！', code: 200 })
        }
        else {
            res.json({ data: null, msg: '该订单不存在详情图片！', code: 200 })
        }
    })
})
module.exports = router;
